package clientproxy

import (
	"go_stu/4_helloworld/hanlder"
	"net/rpc"
)

type HelloSerivceStub struct {
	*rpc.Client
}

// 初始化对象
func NewHelloSerivceClient(protcol, address string) HelloSerivceStub {
	conn, err := rpc.Dial(protcol, address)
	if err != nil {
		panic(err.Error())
	}
	return HelloSerivceStub{conn}
}

func (c *HelloSerivceStub) Hello(request string, reply *string) error {
	err := c.Call(hanlder.HelloServiceName+".Hello", request, reply)
	if err != nil {
		return err
	}
	return nil
}
